Imports BusinessLogicLayer
Imports BusinessLogicLayer.BLMain
Imports BusinessLogicLayer.BLException
Imports DataAccessLayer
Imports UniversalLayer
Imports UniversalLayer.ULMain
Imports UniversalLayer.ULConverter

Public NotInheritable Class frmEntertainmentMgr
    Public bShowSearchbar As Boolean = True
    'Dim _GUIPopulator As EntertainmentManager.GUIPopulator
    'Dim _BLMain As BLMain
    Dim _BLDisposer As New BLDisposer(Handle)
    'Dim _DLMain As DLMain
    'Dim _DLReader As DLReader
    'Dim _DLWriter As DLWriter
    'Dim _DLEntertainment As DLEntertainment
    'Dim _DLSettings As DLSettings
    'Dim iIntermediate As Integer = 0
    Friend dtSearch, dtRecordDetails As DataTable
    Friend dtSettingsMain As DataTable
    Friend sSearchSQL As String = "", sSuggestionSQL As String = " ", sWatchlistSQL As String = " "
    Friend sCategory, sCondition As String
    'Dim iRateStyle As eRateStyle '= MovieManager.eRateStyle.Star
    ''' <summary>
    ''' Entertainment Type :: Muvee / TVSeries
    ''' </summary>
    ''' <remarks></remarks>
    Friend iEntertainmentType As eEntertainmentType
    Public iTimerCounter As Integer
    Public iTimerMax As Integer
    ''' <summary>
    ''' Application Launch Time
    ''' </summary>
    ''' <remarks></remarks>
    Friend Shared ReadOnly tAppLaunchTime As DateTime = Now
    ''' <summary>
    ''' Connection String
    ''' </summary>
    ''' <remarks></remarks>
    Friend Shared ReadOnly sConnectionString As String = My.Settings.constrMovieMgr
    ''' <summary>
    ''' Application StartUp Path
    ''' </summary>
    ''' <remarks></remarks>
    Friend Shared ReadOnly sApplicationPath As String = Application.StartupPath.TrimEnd("\"c)
    'Friend sCategoryInFocus As String

    ''' <summary>
    ''' Initializes Main Form and GUI
    ''' </summary>
    ''' <remarks></remarks>
    Public Sub New()
        Dim _DLSettings As DLSettings
        Dim _frmSplash As EntertainmentManager.frmSplash
        Try
            _DLSettings = New DLSettings
            dtSettingsMain = _DLSettings.FetchAllSettings ' CType(_DLSettings.FetchSettings("", "", "", DLSettings.eSettingsReturnType.DataTable), DataTable)

            'If CBool(_DLSettings.FetchOneSetting(dtSettingsMain, "Login", "Enabled")) Then
            If CBool(DLSettings.FetchOneSetting(dtSettingsMain, "Login", "Enabled")) Then
                _frmSplash = New EntertainmentManager.frmSplash(dtSettingsMain)
                _frmSplash.ShowDialog(Me)
                _frmSplash.Dispose()
            End If
        Catch ex As Exception
            MessageBox.Show("Error: " & ex.Message & vbCrLf & vbCrLf & "Details:" & vbCrLf & ex.ToString, "Error: frmEntertainmentMgr.New", MessageBoxButtons.OK, MessageBoxIcon.Error)
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.New", False)
        Finally
            _frmSplash = Nothing
            _DLSettings = Nothing
            _BLDisposer.Dispose()
        End Try

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        Try
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            'Dim bShowSuggestions As Boolean = Not Equals(dtSettings.Select("Meta='Suggestions' AND ID='Enabled'").Length, 0)
            '_GUIPopulator.DisplaySuggestedResults(Me, bShowSuggestions)
            _GUIPopulator.DisplaySuggestedResults(Me, False) 'always HIDE on start
            'bShowSuggestions = Nothing

        Catch ex As Exception
            MessageBox.Show("Error: " & ex.Message & vbCrLf & vbCrLf & "Details:" & vbCrLf & ex.ToString, "Error: frmEntertainmentMgr.New", MessageBoxButtons.OK, MessageBoxIcon.Error)
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.New")
            End
        Finally
            _GUIPopulator = Nothing
        End Try
    End Sub

    Private Sub frmEntMgr_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        MessageBox.Show("Write SETTINGS to DB in frmEntertainmentMgr.frmEntMgr_FormClosing(sender, e)", "TIP")

        'For Each frm As Form In My.Application.OpenForms
        '    'frm.Close()
        'Next
        _BLDisposer.Dispose()
        GC.Collect()
        Me.Dispose()
        Me.Finalize()
    End Sub

    Private Sub frmEntMgr_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator

        '' ''Dim _frmLogin As EntertainmentManager.frmLogin
        '' ''Try
        '' ''    '' ''_frmLogin = New EntertainmentManager.frmLogin
        '' ''    '' ''_GUIPopulator.HideAllControls(Me, True)
        '' ''    '' ''Me.Hide()
        '' ''    '' ''_frmLogin.ShowDialog(Me)
        '' ''    '' ''pnlHideControls.Visible = False
        '' ''    '' ''pnlHideControls.Cursor = Cursors.Default
        '' ''    '' ''Me.Show()
        '' ''    '' ''_GUIPopulator.HideAllControls(Me, False)
        '' ''Catch ex As Exception
        '' ''    ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.frmEntMgr_Load")
        '' ''Finally
        '' ''    '' ''_frmLogin.Dispose()
        '' ''    '' ''_BLDisposer.Dispose()
        '' ''End Try

        Try
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            'TODO: This line of code loads data into the 'DsMuvee.MuveeDetailsView' table. You can move, or remove it, as needed.
            'Me.MuveeDetailsViewTableAdapter.Fill(Me.DsMuvee.MuveeDetailsView)

            'Dim dt As New DataTable
            '_DLReader = New DLReader
            '_DLReader.ReadXML(Application.StartupPath & "\MovieManager.exe.config", dt)
            'End
            'Dim a As Object = _DLReader.FetchSettings("Clipboard", , , DLSettings.eSettingsReturnType.DLSettings)
            'End
            'Dim sText As String = My.Computer.Clipboard.GetText
            'MessageBox.Show(sText, "ClipboardText")
            'Dim sEcrypted As String = _BLMain.TestReturnCrypto(sText, "BizNewz")
            'MessageBox.Show(sEcrypted, "EncryptedText")
            'My.Computer.Clipboard.SetText(sEcrypted)
            'End

            'tAppLaunchTime = Now
            'Call _GUIPopulator.InitializeControls(Me)
            Call _GUIPopulator.InitializeFormMain(Me)
            'iRateStyle = eRateStyle.Meter

            'Me.WindowState = FormWindowState.Maximized
            tmrNow.Enabled = True
            statusAppName.Text = Application.ProductName
            srchKeyword.Focus()
            'mnuCorporate.Text = "TCS"
            'mnuCorporate.Image = MovieManager.My.Resources.Resources.tata 'Application.StartupPath & "\img\corporate.jpg"

        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.frmEntMgr_Load")
            MessageBox.Show("Error: " & ex.Message & vbCrLf & vbCrLf & "Details:" & vbCrLf & ex.ToString, "Error: frmEntertainmentMgr.frmEntMgr_Load", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End
        Finally
            _GUIPopulator = Nothing
        End Try
    End Sub

    Private Sub frmEntMgr_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
        Try
            'statusMain.Top = Me.Height - 200
            If Me.WindowState <> FormWindowState.Minimized Then Me.WindowState = FormWindowState.Maximized
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.frmEntMgr_Resize")
        End Try
    End Sub

    Private Sub picPosterPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picPosterPreview.Click
        Dim _frmPoster As EntertainmentManager.frmPoster
        Try
            _frmPoster = New EntertainmentManager.frmPoster
            _frmPoster.picPoster.Image = picPosterPreview.Image
            _frmPoster.StartPosition = FormStartPosition.Manual
            _frmPoster.Left = MousePosition.X
            _frmPoster.Top = MousePosition.Y
            _frmPoster.StartPosition = FormStartPosition.CenterScreen
            _frmPoster.ShowDialog(Me)
            _frmPoster.Dispose()
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.picPosterPreview_Click")
        Finally
            _frmPoster = Nothing
            _BLDisposer.Dispose()
        End Try
    End Sub

#Region "Menu Strip"

    Private Sub mnuPosters_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuPosters.Click

    End Sub

#Region "MENU : Admin"

    Private Sub mnuApprovalsAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuApprovalsAll.Click
        MessageBox.Show("UNDER Construction")
    End Sub

    Private Sub mnuApprovalsPending_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuApprovalsPending.Click
        MessageBox.Show("UNDER Construction")
    End Sub

    Private Sub mnuApprovalsRejected_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuApprovalsRejected.Click
        MessageBox.Show("UNDER Construction")
    End Sub

    Private Sub mnuUserMgmtAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuUserMgmtAll.Click
        MessageBox.Show("UNDER Construction")
    End Sub

    Private Sub mnuUserMgmtAdmin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuUserMgmtAdmin.Click
        MessageBox.Show("UNDER Construction")
    End Sub

    Private Sub mnuUserMgmtDebugger_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuUserMgmtDebugger.Click
        MessageBox.Show("UNDER Construction")
    End Sub

    Private Sub mnuUserMgmtOthers_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuUserMgmtOthers.Click
        MessageBox.Show("UNDER Construction")
    End Sub

    Private Sub mnuUserMgmtAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuUserMgmtAdd.Click
        MessageBox.Show("UNDER Construction")
    End Sub

    Private Sub mnuUserMgmtRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuUserMgmtRemove.Click
        MessageBox.Show("UNDER Construction")
    End Sub

    Private Sub mnuUserMgmtReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuUserMgmtReset.Click
        MessageBox.Show("UNDER Construction")
    End Sub

    Private Sub mnuRoleMgmtAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuRoleMgmtAll.Click
        MessageBox.Show("UNDER Construction")
    End Sub

    Private Sub mnuRoleMgmtReadOnly_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuRoleMgmtReadOnly.Click
        MessageBox.Show("UNDER Construction")
    End Sub

    Private Sub mnuRoleMgmtReadWrite_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuRoleMgmtReadWrite.Click
        MessageBox.Show("UNDER Construction")
    End Sub

#End Region

#Region "MENU : Debug"

    Private Sub mnuShowDebug_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuShowDebug.Click
        MessageBox.Show("UNDER Construction")
    End Sub

    Private Sub mnuShowError_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuShowError.Click
        MessageBox.Show("UNDER Construction")
    End Sub

    Private Sub mnuCopySearchSQL_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuCopySearchSQL.Click
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        Try
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            My.Computer.Clipboard.SetText(sSearchSQL)

            If CBool(DLSettings.FetchOneSetting(dtSettingsMain, "SQL", "Formatted", "")) Then _
                _GUIPopulator.FormatSQL()
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.mnuCopySearchSQL_Click")
        Finally
            _GUIPopulator = Nothing
        End Try
    End Sub

    Private Sub mnuCopySuggestionSQL_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuCopySuggestionSQL.Click
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        Try
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            My.Computer.Clipboard.SetText(sSuggestionSQL)
            If CBool(DLSettings.FetchOneSetting(dtSettingsMain, "SQL", "Formatted", "")) Then _
                _GUIPopulator.FormatSQL()
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.mnuCopySuggestionSQL_Click")
        Finally
            _GUIPopulator = Nothing
        End Try
    End Sub

    Private Sub mnuCopyWatchlistSQL_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuCopyWatchlistSQL.Click
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        Try
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            My.Computer.Clipboard.SetText(sWatchlistSQL)
            If CBool(DLSettings.FetchOneSetting(dtSettingsMain, "SQL", "Formatted", "")) Then _
                _GUIPopulator.FormatSQL()
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.mnuCopyWatchlistSQL_Click")
        Finally
            _GUIPopulator = Nothing
        End Try
    End Sub

#End Region

#Region "MENU : File"

    Private Sub mnuNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuNew.Click
        'Call mnuNewMuvee_Click(sender, e)
        'RKD: PENDING_20120524: PENDING_design_and_funcionality()

        Dim _frmOptionNew As New EntertainmentManager.frmOptionNew
        _frmOptionNew.StartPosition = FormStartPosition.Manual
        _frmOptionNew.Left = MousePosition.X
        _frmOptionNew.Top = MousePosition.Y
        _frmOptionNew.ShowDialog(Me)
        If _frmOptionNew.radMuvee.Checked Then
            Call mnuNewMuvee_Click(sender, e)
        ElseIf _frmOptionNew.radTVSeries.Checked Then
            Call mnuNewTVSeries_Click(sender, e)
        End If
        _frmOptionNew.Dispose()
    End Sub

    Private Sub mnuUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuUpdate.Click
        'MessageBox.Show(grdMuvee.SelectedRows(0).Cells("colPKey").Value.ToString(), "mnuUpdate_Click") : Exit Sub
        Dim sEntertainmentMainPKey As String
        Dim _DLEntertainment As DLEntertainment

        Try
            If grdMuvee.SelectedRows.Count > 0 And grdMuvee.Rows.Count > 0 Then
                sEntertainmentMainPKey = grdMuvee.SelectedRows(0).Cells("colPKey").Value.ToString()
                '_DLReader.ExecuteSQL("SELECT TOP 1 * FROM MuveeDetailsView WHERE PKey='" & sMovieMainPKey & "'", dtMuvee)
                '_DLEntertainment.FetchOneRecord(_DLEntertainment, dtMuvee.Rows(0))
                _DLEntertainment = New DLEntertainment(CInt(sEntertainmentMainPKey), DLMain.ePosterParent.Details)
                '_DLEntertainment.FetchOneRecord(CInt(sEntertainmentMainPKey))

                Dim _frmDetails As EntertainmentManager.frmDetails
                Try
                    _frmDetails = New EntertainmentManager.frmDetails(sEntertainmentMainPKey, eActionModes.mEdit, iEntertainmentType)
                    _frmDetails._DLEntertainment = _DLEntertainment
                    _frmDetails.ShowDialog(Me)
                    _frmDetails.Dispose()
                Catch ex As Exception
                    ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.mnuUpdate_Click")
                Finally
                    _frmDetails = Nothing
                    _BLDisposer.Dispose()
                End Try
            End If

        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.mnuUpdate_Click")
        Finally
            _DLEntertainment = Nothing
            sEntertainmentMainPKey = Nothing
        End Try
    End Sub

    Private Sub mnuClipboardCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuClipboardCopy.Click
        Dim sSelectedPKey As String
        Dim _DLMain As DLMain
        Dim _DLReader As DLReader
        Dim _DLEntertainment As DLEntertainment

        Try
            _DLMain = New DLMain
            _DLReader = New DLReader("frmEntertainmentMgr")
            'RKD: Build Options page first
            If grdMuvee.Rows.Count > 0 Then
                If grdMuvee.SelectedRows.Count > 0 Then
                    If grdMuvee.SelectedRows(0).Selected Then ' And grdMuvee.SelectedRows.Count > 0 Then
                        'MessageBox.Show(grdMuvee.SelectedRows.Item(0).Cells.Item("colPKey").Value.ToString(), "grdMuvee_SelectionChanged : PKey")

                        sSelectedPKey = grdMuvee.SelectedRows.Item(0).Cells.Item("colPKey").Value.ToString()
                        _DLReader.ExecuteSQL("SELECT TOP 1 * FROM MuveeDetailsView WHERE PKey='" & sSelectedPKey & "'", _DLMain.dtMuvee)
                        _DLEntertainment = New DLEntertainment(CInt(sSelectedPKey), DLMain.ePosterParent.Preview)
                        '_DLEntertainment.FetchOneRecord(_DLMain.dtMuvee.Rows(0))
                        sSelectedPKey = Nothing

                        With _DLEntertainment
                            'For Each item As CheckedListBox In frmSettings.chklstClipboardCols.CheckedItemCollection()
                            '    MessageBox.Show(item.Item(0).ToString)
                            'Next

                            'For i As Integer = 0 To frmSettings.chklstClipboardCols.Items.Count - 1
                            '    If 1 = 1 Then
                            '        frmSettings.chklstClipboardCols.SetItemChecked(i, True)
                            '        frmSettings.chklstClipboardCols.SetItemCheckState(i, CheckState.Checked)
                            '    End If
                            'Next

                            Dim strClipboard As System.Text.StringBuilder
                            Dim _DLSettings As DLSettings
                            Dim dtSettingsClipboard As DataTable
                            Try
                                strClipboard = New System.Text.StringBuilder
                                _DLSettings = New DLSettings(dtSettingsMain)
                                dtSettingsClipboard = New DataTable
                                dtSettingsClipboard = CType(_DLSettings.FetchSettings("Clipboard", , , DLSettings.eSettingsReturnType.DataTable), DataTable)

                                For Each dr As DataRow In dtSettingsClipboard.Select("Value='1'")
                                    Select Case dr("ID").ToString.ToUpper
                                        Case "TITLE/YEAR"
                                            strClipboard.Append("Title :: " & .cTitle & " (" & .cReleaseYear & ")")
                                        Case "TITLE"
                                            strClipboard.Append(dr("ID").ToString & " :: " & .cTitle)
                                        Case "ALTERNATE TITLE"
                                            strClipboard.Append(dr("ID").ToString & " :: " & .cAlternateTitle)
                                        Case "DIRECTOR"
                                            strClipboard.Append(dr("ID").ToString & " :: " & .cDirector)
                                        Case "NUMBER"
                                            strClipboard.Append(dr("ID").ToString & " :: " & .cSerialNo)
                                        Case "SEEN"
                                            strClipboard.Append(ConvertBoolText(dr("ID").ToString, eBooleanStyle.FullText) & " :: ")
                                            Select Case CInt(.cSeen)
                                                Case 0 : strClipboard.Append("No")
                                                Case 1 : strClipboard.Append("Yes")
                                                Case 2 : strClipboard.Append("In Watchlist")
                                            End Select
                                        Case "PLOT"
                                            'strClipboard.Append(dr("ID").ToString & " :: " & .PLOT)
                                        Case "CAST"
                                            'strClipboard.Append(dr("ID").ToString & " :: " & .CAST)
                                        Case "NOTES"
                                            'strClipboard.Append(dr("ID").ToString & " :: " & .NOTES)
                                        Case "RUNTIME"
                                            strClipboard.Append(dr("ID").ToString & " :: " & .cRunTimeMins & " mins")
                                        Case "COUNTRY"
                                            strClipboard.Append(dr("ID").ToString & " :: " & .cCountry)
                                        Case "GENRE"
                                            strClipboard.Append(dr("ID").ToString & " :: " & .cGenre)
                                        Case "STUDIO"
                                            strClipboard.Append(dr("ID").ToString & " :: " & .cStudio)
                                        Case "DISCS"
                                            strClipboard.Append(dr("ID").ToString & " :: x" & .cNDiscs)
                                        Case "IMDBCODE"
                                            strClipboard.Append(dr("ID").ToString & " :: " & .cIMDbCode)
                                        Case "RATING"
                                            strClipboard.Append(dr("ID").ToString & " :: " & .cRatingIMDb & "/" & .cRatingCustom)
                                        Case "VOLUME/COLLECTION"
                                            strClipboard.Append(dr("ID").ToString & " :: " & .cVolume & "/" & .cCollection)
                                        Case "VOLUME"
                                            strClipboard.Append(dr("ID").ToString & " :: " & .cVolume)
                                        Case "COLLECTION"
                                            strClipboard.Append(dr("ID").ToString & " :: " & .cCollection)
                                        Case "IMDB LINK"
                                            strClipboard.Append(dr("ID").ToString & " :: " & .cLinkIMDb)
                                        Case "WIKIPEDIA LINK"
                                            strClipboard.Append(dr("ID").ToString & " :: " & .cLinkWikipedia)
                                        Case "OFFICIAL SITE"
                                            strClipboard.Append(dr("ID").ToString & " :: " & .cLinkOfficial)
                                        Case "NUMBER"
                                            strClipboard.Append(dr("ID").ToString & " :: " & .cSerialNo)
                                    End Select
                                    strClipboard.Append(vbCrLf)
                                    ' Use the IndexOf method to get the index of an item.
                                    'MessageBox.Show(itemChecked.ToString() & " :: is checked. Checked state is: " + _
                                    '    frmSettings.chklstClipboardCols.GetItemCheckState(frmSettings.chklstClipboardCols.Items.IndexOf(itemChecked)).ToString() + ".")
                                Next
                                MessageBox.Show(strClipboard.ToString, "Clipboard Text")
                                My.Computer.Clipboard.SetText(strClipboard.ToString)

                            Finally
                                strClipboard = Nothing
                                _DLSettings = Nothing
                                dtSettingsClipboard = Nothing
                            End Try
                        End With
                    End If
                End If
            End If

        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.mnuClipboardCopy_Click")
        Finally
            sSelectedPKey = Nothing
            _DLEntertainment = Nothing
            _DLReader = Nothing
            _DLMain = Nothing
        End Try
    End Sub

    Private Sub mnuWatchlistAddz(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuWatchlistAdd.Click
        Call btnWatchlistAdd_Click(sender, e)
    End Sub

    Private Sub mnuSearchSelected_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuSearchSelected.Click

    End Sub

#Region "Export/Import"

    Private Sub mnuImportIMDbWatchlist_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuImportIMDbWatchlist.Click
        Dim _DLSettings As DLSettings
        Dim _DLReader As DLReader
        Dim _DLWriter As DLWriter
        Dim diagImportCSVWatchlist As OpenFileDialog
        Dim sInitialDirectory As String
        Dim sExtension As String
        Dim dtWatchlist As DataTable
        Dim sFullFilePath As String = ""

        Try
            _DLSettings = New DLSettings(dtSettingsMain)
            _DLReader = New DLReader("frmEntertainmentMgr")
            _DLWriter = New DLWriter("frmEntertainmentMgr")
            diagImportCSVWatchlist = New OpenFileDialog
            dtWatchlist = New DataTable
            sInitialDirectory = CStr(DLSettings.FetchOneSetting(dtSettingsMain, "Watchlist", "Path", "")) 'Stored as BLANK in DB
            sExtension = CStr(DLSettings.FetchOneSetting(dtSettingsMain, "Watchlist", "Extension", ""))

            diagImportCSVWatchlist.InitialDirectory = IIf(Not IsEmpty(sInitialDirectory), sInitialDirectory, Application.StartupPath & "\files").ToString
            diagImportCSVWatchlist.DefaultExt = IIf(Not IsEmpty(sExtension), sExtension, "csv").ToString
            diagImportCSVWatchlist.Filter = "Comma-separated value (*.csv)|*." & IIf(Not IsEmpty(sExtension), sExtension, "csv").ToString
            diagImportCSVWatchlist.FileName = "WATCHLIST"
            diagImportCSVWatchlist.Multiselect = False
            diagImportCSVWatchlist.CheckFileExists = True

            diagImportCSVWatchlist.ShowDialog(Me)

            If IsEmpty(sFullFilePath) Then sFullFilePath = diagImportCSVWatchlist.FileName
            If IsFileExists(sFullFilePath) Then
                'dtWatchlist = _DLReader.ReadWatchlistCSV(sFullFilePath)
                _DLWriter.WatchlistUpdateToDB(sFullFilePath)
            End If

        Finally
            _DLSettings = Nothing
            _DLReader = Nothing
            _DLWriter = Nothing
            diagImportCSVWatchlist = Nothing
            sInitialDirectory = Nothing
            sExtension = Nothing
            sFullFilePath = Nothing
            dtWatchlist = Nothing
        End Try
    End Sub

#End Region

    Private Sub mnuExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuExit.Click
        Try
            If MessageBox.Show("Do you really want to exit?" & vbTab & "    ", "Confirm Exit..", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) = Windows.Forms.DialogResult.Yes Then End
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.mnuExit_Click")
        End Try
    End Sub

#End Region

#Region "MENU : Edit"

    Private Sub mnuUndo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuUndo.Click
        'rkd()
    End Sub

    Private Sub mnuRedo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuRedo.Click
        'rkd()
    End Sub

    Private Sub mnuCut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuCut.Click
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        Try
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            _GUIPopulator.EditUtility(Me, eClipboardOperation.Cut)
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.mnuCut_Click")
        Finally
            _GUIPopulator = Nothing
        End Try
    End Sub

    Private Sub mnuCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuCopy.Click
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        Try
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            _GUIPopulator.EditUtility(Me, eClipboardOperation.Copy)
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.mnuCopy_Click")
        Finally
            _GUIPopulator = Nothing
        End Try
    End Sub

    Private Sub mnuPaste_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuPaste.Click
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        Try
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            _GUIPopulator.EditUtility(Me, eClipboardOperation.Paste)
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.mnuPaste_Click")
        Finally
            _GUIPopulator = Nothing
        End Try
    End Sub

    Private Sub mnuClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuClear.Click
        Try
            srchKeyword.Focus()
            srchKeyword.Text = ""
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.mnuClear_Click")
        End Try
    End Sub

    Private Sub mnuSelectAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuSelectAll.Click
        Try
            srchKeyword.Focus()
            srchKeyword.SelectAll()
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.mnuSelectAll_Click")
        End Try
    End Sub

#End Region

#Region "Menu : View"

    Private Sub mnuAllowSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuAllowSearch.Click
        Try
            'bShowSearchbar = Not bShowSearchbar
            'mnuStripSearch.Visible = bShowSearchbar
            'mnuAllowSearch.Checked = bShowSearchbar
            'If bShowSearchbar Then mnuAllowSearch.ToolTipText = "Hide Searchbar" Else mnuAllowSearch.Text = "Show Searchbar"

            mnuStripSearch.Enabled = mnuAllowSearch.Checked
            If mnuAllowSearch.Checked Then mnuAllowSearch.ToolTipText = "Click to " & IIf(mnuAllowSearch.Checked, "disable", "enable").ToString & " Searchbar.."
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.mnuAllowSearch_Click")
        End Try
    End Sub

#End Region

#Region "Menu : Poster"

#End Region

#Region "Menu : Loan"

    Private Sub mnuPeople_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuPeople.Click
        Dim _frmPeople As EntertainmentManager.frmPeople
        Try
            _frmPeople = New EntertainmentManager.frmPeople
            _frmPeople.ShowDialog(Me)
            _frmPeople.Dispose()
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.mnuPeople_Click")
        Finally
            _frmPeople = Nothing
            _BLDisposer.Dispose()
        End Try
    End Sub

#End Region

#Region "Menu : Tools"

    Private Sub mnuOptions_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuOptions.Click
        Dim _DLSettings As DLSettings
        Dim _frmSettings As EntertainmentManager.frmSettings
        Try
            _DLSettings = New DLSettings(dtSettingsMain)
            _frmSettings = New EntertainmentManager.frmSettings(Me)
            _frmSettings.dtSettingsMain = dtSettingsMain
            _frmSettings.ShowDialog(Me)
            _frmSettings.Dispose()
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.mnuOptions_Click")
        Finally
            _frmSettings = Nothing
            _DLSettings = Nothing
            _BLDisposer.Dispose()
        End Try

        Try
            'Refresh Settings DataTable
            _DLSettings = New DLSettings(dtSettingsMain)
            dtSettingsMain = _DLSettings.FetchAllSettings 'CType(_DLSettings.FetchSettings("", "", "", DLSettings.eSettingsReturnType.DataTable), DataTable)
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.mnuOptions_Click")
        Finally
            _DLSettings = Nothing
        End Try
    End Sub

#End Region

#Region "Menu : Help"

    Private Sub mnuAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuAbout.Click
        Dim _frmAbout As EntertainmentManager.frmAbout
        Try
            'Me.Hide()
            _frmAbout = New EntertainmentManager.frmAbout
            _frmAbout.ShowDialog(Me)
            _frmAbout.Dispose()
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.mnuAbout_Click")
        Finally
            _frmAbout = Nothing
            _BLDisposer.Dispose()
        End Try
    End Sub

    Private Sub mnuAuthor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuAuthor.Click
        'Do Nothing
    End Sub

    Private Sub mnuIMDbWatchlist_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuIMDbWatchlist.Click
        Try
            System.Diagnostics.Process.Start("http://www.imdb.com/user/ur16219037/watchlist")
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.mnuIMDbWatchlist_Click")
        End Try
    End Sub

    Private Sub mnuGoogle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuGoogle.Click
        Try
            System.Diagnostics.Process.Start("https://plus.google.com/114609586194650482256/", "")
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.mnuGoogle_Click")
        End Try
    End Sub

    Private Sub mnuFacebook_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFacebook.Click
        Try
            System.Diagnostics.Process.Start("https://www.facebook.com/rupakkd", "")
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.mnuFacebook_Click")
        End Try
    End Sub

    Private Sub mnuTwitter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuTwitter.Click
        Try
            System.Diagnostics.Process.Start("https://twitter.com/iamrhythmdivine", "")
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.mnuTwitter_Click")
        End Try
    End Sub

    Private Sub mnuCorporate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuCorporate.Click
        Try
            System.Diagnostics.Process.Start("mailto:rupakk.das@tcs.com", "")
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.mnuCorporate_Click")
        End Try
    End Sub

    Private Sub mnuGMail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuGMail.Click
        Try
            System.Diagnostics.Process.Start("mailto:rupakkd@gmail.com", "")
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.mnuGMail_Click")
        End Try
    End Sub

#End Region

#End Region

    Private Sub tmrNow_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrNow.Tick
        Try
            statusNow.Text = "Today: " & Format(Now, "dd-MM-yyyy HH:mm:ss")
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.tmrNow_Tick")
        End Try
    End Sub

#Region "Muvee Preview"

    Private Sub lblRatingIMDb_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lblRatingIMDb.TextChanged
        Dim sRating As String
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        Dim sRateStyle As String

        Try
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            sRateStyle = CStr(DLSettings.FetchOneSetting(dtSettingsMain, "RateStyle", "IMDb", ""))
            'If Not IsEmpty(dtSettings) Then
            If IsEmpty(lblRateIMDb.Text) Or Not IsNumeric(lblRatingIMDb.Text) Then
                sRating = "00"
            Else
                'sRating = IIf(CInt(_DLEntertainment.cRatingIMDb) < 10, "0", "").ToString & CInt(_DLEntertainment.cRatingIMDb)
                sRating = IIf(CInt(lblRatingIMDb.Text) < 10, "0", "").ToString & lblRatingIMDb.Text
            End If

            sRateStyle = CStr(DLSettings.FetchOneSetting(dtSettingsMain, "RateStyle", "IMDb", ""))
            picRatingIMDb.ImageLocation = Application.StartupPath & "\img\Rate" & sRateStyle & sRating & ".png"
            'End If

        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.lblRatingIMDb_TextChanged")
        Finally
            sRating = Nothing
            sRateStyle = Nothing
            _GUIPopulator = Nothing
        End Try
    End Sub

    Private Sub lblRatingCustom_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lblRatingCustom.TextChanged
        Dim sRating, sRateStyle As String
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator

        Try
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            'If Not IsEmpty(dtSettings) Then
            If IsEmpty(lblRatingCustom.Text) Or Not IsNumeric(lblRatingCustom.Text) Then
                sRating = "00"
            Else
                'sRating = IIf(CInt(_DLEntertainment.cRatingCustom) < 10, "0", "").ToString & CInt(_DLEntertainment.cRatingCustom)
                sRating = IIf(CInt(lblRatingCustom.Text) < 10, "0", "").ToString & lblRatingCustom.Text
            End If

            sRateStyle = CStr(DLSettings.FetchOneSetting(dtSettingsMain, "RateStyle", "Custom", ""))
            picRatingCustom.ImageLocation = Application.StartupPath & "\img\Rate" & sRateStyle & sRating & ".png"
            'End If

        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.lblRatingCustom_TextChanged")
        Finally
            _GUIPopulator = Nothing
            sRateStyle = Nothing
            sRating = Nothing
        End Try
    End Sub

#End Region

#Region "Search Criteria"

    Private Sub srchCategory_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles srchCategory.Click
        '_GUIPopulator.SearchMuveeByView(Me)
    End Sub

    Private Sub srchCategory_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles srchCategory.SelectedIndexChanged
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        Dim _DLMain As DLMain

        Try
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            _DLMain = New DLMain
            If InArray(_DLMain.sFieldsNumeric, srchCategory.Text) AndAlso Not IsNumeric(srchKeyword.Text) Then _
                srchKeyword.Text = ""

            _GUIPopulator.FillComboBox(srchComparator.ComboBox, eModules.Comparator, , srchCategory.Text.Replace(" ", ""))
            'If InArray(DLMain.sFieldsBinary, srchCategory.Text) Then _GUIPopulator.FillComboBox(srchKeyword.ComboBox, eModules.Keyword, True, "Seen") _
            '    Else srchKeyword.DropDownStyle = ComboBoxStyle.DropDown : srchKeyword.ComboBox.DataSource = Nothing : srchKeyword.Items.Clear()
            '_GUIPopulator.FillComboBox(srchKeyword.ComboBox, eModules.Keyword, True, srchCategory.Text, srchKeyword.Text)
            _GUIPopulator.SearchResults(Me)

        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.srchCategory_SelectedIndexChanged")
        Finally
            _DLMain = Nothing
            _GUIPopulator = Nothing
        End Try
    End Sub

    'Private Sub srchComparator_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles srchComparator.Click
    '    'Dim _GUIPopulator as New EntertainmentManager.GUIPopulator
    '    '_GUIPopulator.SearchMuveeByView(Me)
    '    '_GUIPopulator = Nothing
    'End Sub

    Private Sub srchComparator_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles srchComparator.SelectedIndexChanged
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        Try
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            _GUIPopulator.SearchResults(Me)
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.srchComparator_SelectedIndexChanged")
        Finally
            _GUIPopulator = Nothing
        End Try
    End Sub

    Private Sub srchKeyword_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles srchKeyword.GotFocus
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        Dim sValue As String

        Try
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            If Not IsEmpty(srchKeyword.Text) Then
                sValue = CStr(DLSettings.FetchOneSetting(dtSettingsMain, "Suggestions", "Visible", ""))
                _GUIPopulator.DisplaySuggestedResults(Me, Equals(sValue, "1"))
            End If
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.srchKeyword_GotFocus")
        Finally
            _GUIPopulator = Nothing
            sValue = Nothing
        End Try
    End Sub

    Private Sub srchKeyword_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles srchKeyword.KeyDown
        ''If e.Control And e.Alt Then
        ''    Dim sSelected As String = srchKeyword.SelectedText
        ''    Dim sText As String = srchKeyword.Text
        ''    Dim iFlag As Integer = 0
        ''
        ''    Select Case e.KeyData
        ''        Case Keys.C 'Ctrl+C : Cut
        ''            iFlag = 1
        ''            My.Computer.Clipboard.SetText(sSelected)
        ''        Case Keys.X 'Ctrl+X : Copy
        ''            iFlag = 1
        ''            srchKeyword.Text = Mid(sText, 0, srchKeyword.SelectionStart - 1) & Mid(sText, srchKeyword.SelectionStart + srchKeyword.SelectionLength + 1)
        ''        Case Keys.V 'Ctrl+P : Paste
        ''            iFlag = 1
        ''            '
        ''        Case Else
        ''
        ''    End Select
        ''
        ''    'MessageBox.Show((e.KeyValue.ToString) & " : " & e.GetType.ToString & " : " & e.KeyData & " : " & e.Control & " : " & e.Alt & " : " & e.Shift)
        ''    If iFlag = 1 Then MessageBox.Show(My.Computer.Clipboard.GetText)
        ''    statusAppName.Text = My.Computer.Clipboard.GetText
        ''End If        
    End Sub

    Private Sub srchKeyword_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles srchKeyword.KeyPress
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        Dim _DLMain As DLMain
        Dim bShowSuggestion As Boolean

        Try
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            _DLMain = New DLMain
            'If e.KeyChar = CChar(Keys.Enter.ToString) Then MessageBox.Show("ENTER") ' dlWriter.WriteXML(Application.StartupPath, dtSearch)
            If InArray(_DLMain.sFieldsNumeric, srchCategory.Text) Then
                'e.Handled = Not _BLMain.isKeyAllowed(e, BLMain.eKeypressValidation.Numeric)
                Call IsKeyAllowed(e, eKeypressValidation.Numeric)
            End If

            bShowSuggestion = CBool(DLSettings.FetchOneSetting(dtSettingsMain, "Suggestions", "Visible", ""))
            If Not InArray(_DLMain.sFieldsStringMax, srchCategory.Text) Then _
               _GUIPopulator.DisplaySuggestedResults(Me, bShowSuggestion)

        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.srchKeyword_KeyPress")
        Finally
            _DLMain = Nothing
            _GUIPopulator = Nothing
            bShowSuggestion = Nothing
        End Try
    End Sub

    Private Sub srchKeyword_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles srchKeyword.KeyUp
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        Try
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            _GUIPopulator.FillSuggestions(Me, sCategory, sCondition)
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.srchKeyword_KeyUp")
        Finally
            _GUIPopulator = Nothing
        End Try
    End Sub

    Private Sub srchKeyword_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles srchKeyword.Click
        'Dim _GUIPopulator as New EntertainmentManager.GUIPopulator
        '_GUIPopulator.SearchMuveeByView(Me)
        '_GUIPopulator = Nothing
    End Sub

    'Private Sub srchKeyword_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles srchKeyword.SelectedIndexChanged
    '    Dim _GUIPopulator as New EntertainmentManager.GUIPopulator(Me)
    '    _GUIPopulator.SearchResults(Me)
    '    _GUIPopulator = Nothing
    'End Sub

    Private Sub srchKeyword_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles srchKeyword.TextChanged
        'If iIntermediate = 0 Then iIntermediate = 1 Else iIntermediate += 1

        ''OPTION 0:
        'Dim sCategory, sKeyWord As String
        ''Dim sCondition As String
        'sCategory = srchCategory.Text.Replace(" ", "")
        'sKeyWord = srchKeyword.Text '.Trim
        'SendKeys.Send("{End}")
        '_GUIPopulator.FillComboBox(srchKeyword.ComboBox, eModules.Keyword, True, srchCategory.Text.Replace(" ", ""), srchKeyword.Text)

        'Dim dtKeywords As New DataTable, _DLReader As New DLReader
        'srchKeyword.ComboBox.DataSource = Nothing
        'If IsEmpty(srchKeyword.ComboBox.DataSource) Then srchKeyword.ComboBox.Items.Clear()
        ''OPTION 1:
        'sCondition = "(" & sCategory & " = '" & sKeyWord & "' OR " & sCategory & " like '%" & sKeyWord & "%' OR " & sCategory & " like '%" & sKeyWord.Replace(" ", "%") & "%')"
        'sCondition = sCategory & " like '" & sKeyWord & "%'"
        'dlReader.ExecuteSQL("SELECT " & srchCategory.Text.Replace(" ", "") & " FROM MuveeDetailsView WHERE " & sCondition, dtKeywords)
        ''OPTION 2:
        ''dlReader.FetchKeyword(dtKeywords, sCategory, sKeyWord)
        'srchKeyword.ComboBox.DataSource = dtKeywords
        'srchKeyword.ComboBox.DisplayMember = "" 'sCategory.Replace(" ", "")
        'srchKeyword.ComboBox.ValueMember = "" 'sCategory.Replace(" ", "")
        ''srchKeyword.ComboBox.Sorted = True
        'srchKeyword.ComboBox.DropDownStyle = ComboBoxStyle.DropDown
        'srchKeyword.ComboBox.SelectedIndex = -1

        Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        Try
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            _GUIPopulator.SearchResults(Me)
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.srchKeyword_TextChanged")
        Finally
            _GUIPopulator = Nothing
        End Try
    End Sub

    'Private Sub srchCollection_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles srchCollection.Click
    '    'Dim _GUIPopulator as New EntertainmentManager.GUIPopulator
    '    '_GUIPopulator.SearchMuveeByView(Me)
    '    '_GUIPopulator = Nothing
    'End Sub

    Private Sub srchCollection_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles srchCollection.SelectedIndexChanged
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        Try
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            _GUIPopulator.SearchResults(Me)
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.srchCollection_SelectedIndexChanged")
        Finally
            _GUIPopulator = Nothing
        End Try
    End Sub

    'Private Sub srchVolume_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles srchVolume.Click
    '    'Dim _GUIPopulator as New EntertainmentManager.GUIPopulator
    '    '_GUIPopulator.SearchMuveeByView(Me)
    '    '_GUIPopulator = Nothing
    'End Sub

    Private Sub srchVolume_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles srchVolume.SelectedIndexChanged
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        Try
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            _GUIPopulator.SearchResults(Me)
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.srchVolume_SelectedIndexChanged")
        Finally
            _GUIPopulator = Nothing
        End Try
    End Sub

    Private Sub srchLoanedTo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles srchLoaned.Click
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        Try
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            _GUIPopulator.SearchResults(Me)
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.srchLoanedTo_Click")
        Finally
            _GUIPopulator = Nothing
        End Try
    End Sub

    Private Sub srchLoanedTo_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles srchLoaned.SelectedIndexChanged
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        Try
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            _GUIPopulator.SearchResults(Me)
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.srchLoanedTo_SelectedIndexChanged")
        Finally
            _GUIPopulator = Nothing
        End Try
    End Sub

#End Region

#Region "Links"

    Private Sub lnkIMDb_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles lnkIMDb.LinkClicked
        Try
            System.Diagnostics.Process.Start(lnkIMDb.Text)
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.lnkIMDb_LinkClicked")
        End Try
    End Sub

    Private Sub lnkOfficial_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles lnkOfficial.LinkClicked
        Try
            System.Diagnostics.Process.Start(lnkOfficial.Text)
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.lnkOfficial_LinkClicked")
        End Try
    End Sub

    Private Sub lnkWiki_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles lnkWiki.LinkClicked
        Try
            System.Diagnostics.Process.Start(lnkWiki.Text)
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.lnkWiki_LinkClicked")
        End Try
    End Sub

    Private Sub lnkTrailer_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles lnkTrailer.LinkClicked
        Try
            System.Diagnostics.Process.Start(lnkTrailer.Text)
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.lnkTrailer_LinkClicked")
        End Try
    End Sub

#End Region

    Private Sub grdMuvee_CellMouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles grdMuvee.CellMouseDoubleClick
        Call mnuUpdate_Click(sender, e) 'Opens details screen if Ctrl+Click is pressed
    End Sub

    Private Sub grdMuvee_CellMouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles grdMuvee.CellMouseDown
        If ModifierKeys = Keys.ControlKey And MouseButtons = Windows.Forms.MouseButtons.Left Then _
            Call mnuUpdate_Click(sender, e) : Exit Sub 'Opens details screen if Ctrl+Click is pressed

        Dim sSelectedPKey As String
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        Try
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            If e.RowIndex >= 0 And e.Button = Windows.Forms.MouseButtons.Left Then
                'MessageBox.Show(e.RowIndex & "," & e.ColumnIndex)
                'MessageBox.Show(grdMuvee.Rows(e.RowIndex).Cells("colPKey").Value.ToString, "PKey") 'PKey
                ''MessageBox.Show(grdMuvee.Rows(e.RowIndex).Cells("colSerialNo").Value.ToString, "SerialNo") 'SerialNo
                'MessageBox.Show(grdMuvee.Rows(e.RowIndex).Cells("colTitle").Value.ToString, "Title") 'Title
                ''MessageBox.Show(grdMuvee.Rows(e.RowIndex).Cells("colSeen").Value.ToString, "Seen") 'Seen
                ''MessageBox.Show(grdMuvee.Rows(e.RowIndex).Cells("colIMDbLink").Value.ToString, "IMDbLink") 'IMDbLink

                'sSelectedPKey = grdMuvee.Rows(e.RowIndex).Cells("colPKey").Value.ToString 'grdMuvee.SelectedCells.Item(0).OwningRow.Cells.Item(0).Value.ToString
                ''   MessageBox.Show("PKey = " & sSelectedPKey, "PKey")
                '_GUIPopulator.FillPreview(Me, sSelectedPKey)
                'sSelectedPKey = Nothing

                If e.ColumnIndex() = grdMuvee.Rows(e.RowIndex).Cells("colIMDbLink").ColumnIndex Then _
                System.Diagnostics.Process.Start(grdMuvee.Rows(e.RowIndex).Cells("colIMDbLink").Value.ToString)

            ElseIf e.RowIndex >= 0 And e.Button = Windows.Forms.MouseButtons.Right Then
                grdMuvee.Rows(e.RowIndex).Selected = True
                If grdMuvee.Rows(e.RowIndex).Cells("colSeen").Value.ToString = "1" Then cmnuSeenUnseen.Text = "Un&seen" _
                Else cmnuSeenUnseen.Text = "&Seen"
                'RKD: add update code
                'MessageBox.Show(e.RowIndex & "," & e.ColumnIndex)
                'MessageBox.Show(grdMuvee.Rows(e.RowIndex).Cells("colTitle").Value.ToString) 'Title

            End If
            ' If e.RowIndex >= 0 Then grdMuvee.CurrentCell = grdMuvee.Rows(e.RowIndex).Cells(e.ColumnIndex)

        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.grdMuvee_CellMouseDown")
        Finally
            sSelectedPKey = Nothing
            _GUIPopulator = Nothing
        End Try
    End Sub

    Private Sub grdMuvee_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdMuvee.SelectionChanged
        Dim sSelectedPKey As String
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator

        Try
            'MsgBox("BEFORE")
            If srchCategory.Text.Length = 0 OrElse srchComparator.Text.Length = 0 OrElse _
            srchVolume.SelectedIndex = -1 OrElse srchCollection.SelectedIndex = -1 Then Exit Sub

            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            If grdMuvee.Rows.Count > 0 Then
                If grdMuvee.SelectedRows.Count > 0 Then
                    If grdMuvee.SelectedRows(0).Selected Then ' And grdMuvee.SelectedRows.Count > 0 Then
                        'MessageBox.Show(grdMuvee.SelectedRows.Item(0).Cells.Item("colPKey").Value.ToString(), "grdMuvee_SelectionChanged : PKey")

                        Try
                            sSelectedPKey = CStr(grdMuvee.SelectedRows.Item(0).Cells.Item("colPKey").Value)
                        Catch ex As Exception
                            'sSelectedPKey = ""
                            sSelectedPKey = Nothing
                            Exit Sub
                        End Try
                        If Not IsEmpty(sSelectedPKey) Then _GUIPopulator.FillPreview(Me, sSelectedPKey)

                    End If
                End If
            End If

        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.grdMuvee_SelectionChanged")
        Finally
            sSelectedPKey = Nothing
            _GUIPopulator = Nothing
        End Try
    End Sub

    'Private Sub grdMuvee_CellStateChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellStateChangedEventArgs) Handles grdMuvee.CellStateChanged
    '    'If Not e.StateChanged = DataGridViewElementStates.Selected Then grdMuvee.CurrentCell.Selected = False
    'End Sub

#Region "Context Menu"

    Private Sub cmnuNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmnuNew.Click
        Call mnuNew_Click(sender, e)
    End Sub

    Private Sub cmnuUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmnuUpdate.Click
        Call mnuUpdate_Click(sender, e)
    End Sub

    Private Sub cmnuClipboardCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmnuClipboardCopy.Click
        Call mnuClipboardCopy_Click(sender, e)
    End Sub

    Private Sub cmnuWatchlistAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmnuWatchlistAdd.Click
        Call btnWatchlistAdd_Click(sender, e)
    End Sub

    Private Sub cmnuSeenUnseen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmnuSeenUnseen.Click
        Dim sSQL As String
        Dim sSeen As String
        Dim sSelectedPKey As String
        Dim _DLMain As DLMain
        Dim _DLReader As DLReader
        Dim _DLWriter As DLWriter
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator

        Try
            _DLMain = New DLMain
            _DLReader = New DLReader("frmEntertainmentMgr")
            _DLWriter = New DLWriter("frmEntertainmentMgr")
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)

            If grdMuvee.Rows.Count > 0 Then
                If grdMuvee.SelectedRows.Count > 0 Then
                    If grdMuvee.SelectedRows(0).Selected Then ' And grdMuvee.SelectedRows.Count > 0 Then
                        sSelectedPKey = grdMuvee.SelectedRows.Item(0).Cells.Item("colPKey").Value.ToString()

                        sSQL = "SELECT tmpSeen AS Seen FROM EntertainmentMain WHERE PKey='" & sSelectedPKey & "'"
                        sSeen = _DLReader.ExecuteSQL(sSQL).Item("Seen").ToString
                        sSQL = "UPDATE EntertainmentMain SET tmpSeen='" & ToggleBoolText(sSeen) & "' WHERE PKey='" & sSelectedPKey & "'"
                        Call _DLWriter.ExecuteTransactSQL(sSQL, DLWriter.eTransactSQL.Update)
                        _GUIPopulator.FillPreview(Me, sSelectedPKey)

                    End If
                End If
            End If

        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.cmnuSeenUnseen_Click")
        Finally
            sSQL = Nothing
            sSeen = Nothing
            _DLMain = Nothing
            _DLWriter = Nothing
            _DLReader = Nothing
            sSelectedPKey = Nothing
            _GUIPopulator = Nothing
        End Try
    End Sub

    Private Sub cmnuChangePoster_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmnuChangePoster.Click
        MessageBox.Show("Add Code HERE")
    End Sub

#End Region

    Private Sub btnVolume_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnVolume.Click
        Try
            srchKeyword.Text = ""
            'srchKeyword.SelectedIndex = -1
            srchKeyword.Text = ""
            srchCollection.SelectedIndex = 0
            srchVolume.Text = lblVolume.Text
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.btnVolume_Click")
        End Try
    End Sub

    Private Sub btnCollection_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCollection.Click
        Try
            srchKeyword.Text = ""
            'srchKeyword.SelectedIndex = -1
            srchKeyword.Text = ""
            srchVolume.SelectedIndex = 0
            srchCollection.Text = lblCollection.Text
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.btnCollection_Click")
        End Try
    End Sub

    Private Sub mnuNewMuvee_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuNewMuvee.Click
        'RKD
        'Dim iActionMode As New BLMain.eActionModes
        'Dim setActionMode As New MovieManager.frmDetails.eActionModes

        'iActionMode = BLMain.eActionModes.mNew
        'iActionMode = BLMain.eActionModes.mEdit
        'setActionMode = CInt(iActionMode.GetHashCode)

        Dim _DLReader As DLReader
        Dim _frmDetails As EntertainmentManager.frmDetails
        'Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        Try
            _DLReader = New DLReader("frmEntertainmentMgr")
            _frmDetails = New EntertainmentManager.frmDetails(_DLReader.FetchNextIdentity("EntertainmentMain").ToString, eActionModes.mNew, eEntertainmentType.Muvees)
            '_GUIPopulator = New EntertainmentManager.GUIPopulator(frmDetails)
            '_GUIPopulator.FillDetailsFields(frmDetails)
            _frmDetails.ShowDialog(Me)
            _frmDetails.Dispose()

        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.mnuNewMuvee_Click")
        Finally
            _frmDetails = Nothing
            _BLDisposer.Dispose()
            '_GUIPopulator = Nothing
            _DLReader = Nothing
        End Try
    End Sub

    Private Sub mnuNewTVSeries_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuNewTVSeries.Click
        Dim _DLReader As DLReader
        Dim _frmDetails As EntertainmentManager.frmDetails
        'Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        Try
            _DLReader = New DLReader("frmEntertainmentMgr")
            _frmDetails = New EntertainmentManager.frmDetails(_DLReader.FetchNextIdentity("EntertainmentMain").ToString, eActionModes.mNew, eEntertainmentType.TVSeries)
            '_GUIPopulator = New EntertainmentManager.GUIPopulator(frmDetails)
            '_GUIPopulator.FillDetailsFields(_frmDetails)
            _frmDetails.ShowDialog(Me)
            _frmDetails.Dispose()

        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.mnuNewTVSeries_Click")
        Finally
            _frmDetails = Nothing
            _BLDisposer.Dispose()
            '_GUIPopulator = Nothing
            _DLReader = Nothing
        End Try
    End Sub

    Private Sub mnuNewSeason_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuNewSeason.Click
        MessageBox.Show("Under Construction", "mnuNewSeason_Click")
    End Sub

    Private Sub mnuNewEpisode_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuNewEpisode.Click
        MessageBox.Show("Under Construction", "mnuNewEpisode_Click")
    End Sub

    Private Sub lblDirector_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblDirector.Click
        Try
            srchKeyword.Text = txtDirector.Text
            srchCategory.Text = "Director"
            'srchVolume.SelectedIndex = -1
            'srchCollection.SelectedIndex = -1
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.lblDirector_Click")
        End Try
    End Sub

    Private Sub btnSearchMuvee_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearchMuvee.Click
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        Try
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            _GUIPopulator.SearchResults(Me)
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.btnSearchMuvee_Click")
        Finally
            _GUIPopulator = Nothing
        End Try
    End Sub

    Private Sub btnClearFilters_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClearFilters.Click
        Try
            srchCategory.SelectedIndex = 0
            srchComparator.SelectedIndex = 0
            srchVolume.SelectedIndex = 0
            srchCollection.SelectedIndex = -1
            srchLoaned.SelectedIndex = -1
            srchKeyword.Text = ""
            'srchKeyword.DropDownStyle = ComboBoxStyle.DropDown
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.btnClearFilters_Click")
        End Try
    End Sub

    Private Sub mnuToggleMuvees_CheckStateChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuToggleMuvees.CheckStateChanged
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        Try
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            'If mnuToggleMuvees.Checked Then Call mnuToggleMuvees_Click(sender, e)
            If mnuToggleMuvees.Checked Then
                If mnuToggleMuvees.Checked Then
                    iEntertainmentType = eEntertainmentType.Muvees
                    grpIMDb.Text = ".: Movie @ IMDb :."
                    grpWiki.Text = ".: Movie @ Wiki :."
                    mnuToggleTVSeries.Checked = False
                    _GUIPopulator.SearchResults(Me)
                End If
            End If
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.mnuToggleMuvees_CheckStateChanged")
        Finally
            _GUIPopulator = Nothing
        End Try
    End Sub

    Private Sub mnuToggleMuvees_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuToggleMuvees.Click
        Try
            mnuToggleMuvees.Checked = Not mnuToggleMuvees.Checked
            'If mnuToggleMuvees.Checked Then
            '    iEntertainmentType = eEntertainmentType.Muvees
            '    Dim _GUIPopulator as New EntertainmentManager.GUIPopulator
            '    mnuToggleTVSeries.Checked = False
            '    _GUIPopulator.SearchResults(Me)
            '    _GUIPopulator = Nothing
            'End If
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.mnuToggleMuvees_Click")
        End Try
    End Sub

    Private Sub mnuToggleTVSeries_CheckStateChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuToggleTVSeries.CheckStateChanged
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        Try
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            'If mnuToggleTVSeries.Checked Then Call mnuToggleTVSeries_Click(sender, e)
            If mnuToggleTVSeries.Checked Then
                iEntertainmentType = eEntertainmentType.TVSeries
                grpIMDb.Text = ".: TV Series @ IMDb :."
                grpWiki.Text = ".: TV Series @ Wiki :."
                mnuToggleMuvees.Checked = False
                _GUIPopulator.SearchResults(Me)
            End If
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.mnuToggleTVSeries_CheckStateChanged")
        Finally
            _GUIPopulator = Nothing
        End Try
    End Sub

    Private Sub mnuToggleTVSeries_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuToggleTVSeries.Click
        Try
            mnuToggleTVSeries.Checked = Not mnuToggleTVSeries.Checked
            'If mnuToggleTVSeries.Checked Then
            '    iEntertainmentType = eEntertainmentType.TVSeries
            '    Dim _GUIPopulator as New EntertainmentManager.GUIPopulator
            '    mnuToggleMuvees.Checked = False
            '    _GUIPopulator.SearchResults(Me)
            '    _GUIPopulator = Nothing
            'End If
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.mnuToggleTVSeries_Click")
        End Try
    End Sub

    Private Sub statusNow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles statusNow.Click
        Try
            MessageBox.Show("Running for " & DateDiff(DateInterval.Minute, tAppLaunchTime, Now) & "mins..", "Duration")
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.statusNow_Click")
        End Try
    End Sub

    Private Sub btnWatchlistAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWatchlistAdd.Click
        'Dim sSQL As String = ""
        'Dim dtWatchlist As DataTable
        'Dim _DLReader As DLReader
        Dim _DLWriter As DLWriter
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator

        Try
            'dtWatchlist = New DataTable
            '_DLReader = New DLReader
            _DLWriter = New DLWriter("frmEntertainmentMgr")
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            '_DLReader.ExecuteSQL("SELECT * FROM WatchlistView WHERE EntertainmentMainPKey = '" & txtPreviewPKey.Text & "' AND Seen = 2 ORDER BY DateAdded DESC", dtWatchlist)

            'If dtWatchlist.Rows.Count = 0 Then
            '    'sSQL = "INSERT INTO WatchlistMain(EntertainmentMainPKey, DateAdded) VALUES('" & txtPreviewPKey.Text & "', '" & Now.Date & "')"
            '    sSQL = "INSERT INTO WatchlistMain(EntertainmentMainPKey, DateAdded) VALUES(" & txtPreviewPKey.Text & ", convert(varchar,current_timestamp,110))"
            'Else
            '    If btnWatchlistAdd.Enabled Then MessageBox.Show("The item has already been added into watchlist" & vbCrLf & "on " & Format(CDate(dtWatchlist.Rows(0).Item("DateAdded")), "dd-MMM-yyyy"), "Watchlist", MessageBoxButtons.OK, MessageBoxIcon.Information)
            '    btnWatchlistAdd.Enabled = False
            'End If
            'If Not IsEmpty(sSQL) Then Call _DLWriter.ExecuteTransactSQL(sSQL, DLWriter.eTransactSQL.Insert)

            _DLWriter.WatchlistAdd(txtPreviewPKey.Text)
            _GUIPopulator.FillPreviewWatchlist(Me, txtPreviewPKey.Text, "", CStr(DLSettings.FetchOneSetting(dtSettingsMain, "Watchlist", "PreviewSort")))

        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.btnWatchlistAdd_Click")
        Finally
            'sSQL = Nothing
            '_DLReader = Nothing
            'dtWatchlist = Nothing
            _DLWriter = Nothing
            _GUIPopulator = Nothing
        End Try
    End Sub

    Private Sub btnWatchlistToday_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWatchlistToday.Click
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        Dim _frmCalendar As EntertainmentManager.frmCalendar
        Dim dateWatched As DateTime
        Try
            'calWatchlistToday.Visible = True
            _frmCalendar = New EntertainmentManager.frmCalendar
            _frmCalendar.ShowDialog(Me)
            dateWatched = _frmCalendar.dateSelected
            _frmCalendar.Dispose()

            ''Select Case MessageBox.Show("You sure?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
            ''    Case Windows.Forms.DialogResult.Yes
            Dim _BLMain As BusinessLogicLayer.BLMain
            Try
                If dateWatched.Date = Today.Date Then dateWatched = Now
                _BLMain = New BusinessLogicLayer.BLMain(BLMain.eInitMode.Actions)
                _BLMain.WatchlistToday(txtPreviewPKey.Text, dateWatched)
                'calWatchlistToday.Visible = False
            Finally
                _BLMain = Nothing
                'dateWatched = Nothing
            End Try
            ''
            ''    Case Windows.Forms.DialogResult.No
            ''        'Do Nothing
            ''End Select

            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            _GUIPopulator.FillPreviewWatchlist(Me, txtPreviewPKey.Text, "", CStr(DLSettings.FetchOneSetting(dtSettingsMain, "Watchlist", "PreviewSort")))

        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.btnWatchlistToday_Click")
        Finally
            _GUIPopulator = Nothing
        End Try
    End Sub

    Private Sub mnuViewWatchlist_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuViewWatchlist.Click
        Dim _frmWatchlist As EntertainmentManager.frmWatchlist
        Dim _DLReader As DLReader
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        Dim dtWatchlist As DataTable
        Dim sSQL As String

        Try
            _frmWatchlist = New EntertainmentManager.frmWatchlist
            _DLReader = New DLReader("frmEntertainmentMgr")
            _GUIPopulator = New EntertainmentManager.GUIPopulator(_frmWatchlist)
            dtWatchlist = New DataTable
            sSQL = "IF NOT EXISTS (SELECT 1 FROM WatchlistView) " & _
                   "	SELECT '--' as PKey,'--' as EntertainmentMainPKey,'--' as TitleDirector,'--' as RunTime,'--' as Rating,'--' as Seen,'--' as DateAdded,'--' as DateWatched " & _
                   "ELSE SELECT PKey, EntertainmentMainPKey, TitleDirector, RunTime, Rating, Seen, DateAdded, DateWatched FROM WatchlistView ORDER BY " & CStr(DLSettings.FetchOneSetting(dtSettingsMain, "Watchlist", "WatchlistSort"))
            _DLReader.ExecuteSQL(sSQL, dtWatchlist)

            '_GUIPopulator.InitializeGrids(eDataGrids.Watchlist)
            'frmWatchlist.grdWatchlist = New DataGridView
            _frmWatchlist.grdWatchlist.DataSource = Nothing
            _frmWatchlist.grdWatchlist.Rows.Clear()
            _frmWatchlist.grdWatchlist.DataSource = dtWatchlist

            _frmWatchlist.grdWatchlist.SelectionMode = DataGridViewSelectionMode.FullRowSelect
            _frmWatchlist.grdWatchlist.MultiSelect = False
            If _frmWatchlist.grdWatchlist.RowCount > 0 Then _frmWatchlist.grdWatchlist.Rows(0).Selected = True
            _frmWatchlist.grdWatchlist.Enabled = Not Equals(_frmWatchlist.grdWatchlist.RowCount, 0)

            _frmWatchlist.StartPosition = FormStartPosition.CenterParent
            _frmWatchlist.ShowDialog(Me)
            _frmWatchlist.Dispose()

        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.mnuViewWatchlist_Click")
        Finally
            _frmWatchlist = Nothing
            _BLDisposer.Dispose()
            _DLReader = Nothing
            dtWatchlist = Nothing
            sSQL = Nothing
        End Try
    End Sub













    Private Sub tmrSuggestion_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrSuggestion.Tick
        iTimerCounter += 1
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        Try
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            _GUIPopulator.SetControlTransparency(CType(lstSuggestions, Control), iTimerCounter, iTimerMax)

            If iTimerCounter = iTimerMax Then
                tmrSuggestion.Enabled = False
                lstSuggestions.Visible = False
            End If

        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.tmrSuggestion_Tick")
        Finally
            _GUIPopulator = Nothing
        End Try
    End Sub

    Private Sub lstSuggestions_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstSuggestions.Click
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        If lstSuggestions.Items.Count > 0 Then 'And lstSuggestions.SelectedItems.Count > 0 Then
            srchKeyword.Text = lstSuggestions.SelectedValue.ToString
        End If

        Try
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            If lstSuggestions.Visible Then
                _GUIPopulator.DisplaySuggestedResults(Me, False)
            End If
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.lstSuggestions_Click")
        Finally
            _GUIPopulator = Nothing
        End Try
    End Sub

    Private Sub lstSuggestions_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles lstSuggestions.DragOver
        'MessageBox.Show("DragOver")
    End Sub

    Private Sub lstSuggestions_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstSuggestions.GotFocus
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        Dim sValue As String

        Try
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            sValue = CStr(DLSettings.FetchOneSetting(dtSettingsMain, "Suggestions", "Visible", ""))
            _GUIPopulator.DisplaySuggestedResults(Me, Equals(sValue, "1"))
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.lstSuggestions_GotFocus")
        Finally
            _GUIPopulator = Nothing
            sValue = Nothing
        End Try
    End Sub

    Private Sub lstSuggestions_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstSuggestions.LostFocus
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        Try
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            If lstSuggestions.Visible Then
                _GUIPopulator.DisplaySuggestedResults(Me, False)
            End If
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.lstSuggestions_LostFocus")
        Finally
            _GUIPopulator = Nothing
        End Try
    End Sub

    Private Sub lstSuggestions_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstSuggestions.MouseHover
        Dim _GUIPopulator As EntertainmentManager.GUIPopulator
        Try
            _GUIPopulator = New EntertainmentManager.GUIPopulator(Me)
            _GUIPopulator.DisplaySuggestedResults(Me, True)
        Catch ex As Exception
            ThrowBLException(ex, "EntertainmentManager.frmEntertainmentMgr.lstSuggestions_MouseHover")
        Finally
            _GUIPopulator = Nothing
        End Try
    End Sub

    Private Sub lstSuggestions_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lstSuggestions.MouseMove
        'MessageBox.Show("MouseMove")
    End Sub

    Private Sub lstSuggestions_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lstSuggestions.MouseWheel
        MessageBox.Show("MouseWheel")
    End Sub

    Private Sub lstSuggestions_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstSuggestions.SelectedIndexChanged

    End Sub

    Private Sub calWatchlistToday_DateSelected(ByVal sender As Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles calWatchlistToday.DateSelected
        Select Case MessageBox.Show("You sure?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
            Case Windows.Forms.DialogResult.Yes
                Dim _BLMain As BusinessLogicLayer.BLMain
                Dim dateWatched As DateTime
                Try
                    _BLMain = New BusinessLogicLayer.BLMain(BLMain.eInitMode.Actions)
                    dateWatched = CDate(e.Start.ToShortDateString)
                    _BLMain.WatchlistToday(txtPreviewPKey.Text, dateWatched)
                    calWatchlistToday.Visible = False
                Finally
                    _BLMain = Nothing
                    dateWatched = Nothing
                End Try

            Case Windows.Forms.DialogResult.No
                'Do Nothing
        End Select
    End Sub

    Private Sub calWatchlistToday_DateChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles calWatchlistToday.DateChanged

    End Sub

    Private Sub CloseAllButMe()
        'For i As Integer = My.Application.OpenForms.Count - 1 To 0 Step -1
        '    If My.Application.OpenForms.Item(i) IsNot Me Then
        '        My.Application.OpenForms.Item(i).Close()
        '    End If
        'Next i

        'Dim openForm As Form = Nothing
        'For index As Integer = My.Application.OpenForms.Count - 1 To 0 Step -1
        '    openForm = My.Application.OpenForms.Item(index)
        '    If openForm IsNot Me AndAlso Not TypeOf openForm Is DevExpress.Utils.Win.TopFormBase Then
        '        openForm.Close()
        '        openForm.Dispose()
        '        openForm = Nothing
        '    End If
        'Next
    End Sub

    Private Sub mnuExpMSExcel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuExpMSExcel.Click
        Dim dlgSaveExcelExport As New SaveFileDialog
        dlgSaveExcelExport.Title = "Export to Excel"
        dlgSaveExcelExport.ValidateNames = True
        'dlgSaveExcelExport.CheckFileExists = True
        dlgSaveExcelExport.RestoreDirectory = True
        dlgSaveExcelExport.CreatePrompt = True
        dlgSaveExcelExport.DereferenceLinks = False
        dlgSaveExcelExport.OverwritePrompt = True
        dlgSaveExcelExport.SupportMultiDottedExtensions = False
        dlgSaveExcelExport.Filter = "Excel 2007 Workbook|*.xlsx|Excel 97-2003 Workbook|*.xls|All files|*.xls, *.xlsx"
        dlgSaveExcelExport.DefaultExt = "xlsx"
        dlgSaveExcelExport.FileName = iEntertainmentType.ToString & "_" & Format(Now, "yyyyMMdd_HHmmss")
        dlgSaveExcelExport.InitialDirectory = sApplicationPath & "\files"
        If Not IsDirectoryExists(dlgSaveExcelExport.InitialDirectory) Then _
            System.IO.Directory.CreateDirectory(dlgSaveExcelExport.InitialDirectory)
        dlgSaveExcelExport.ShowDialog(Me)
        Dim sFileName As String = dlgSaveExcelExport.FileName
        'Dim cur As Cursor = New System.Windows.Forms.Cursor(sApplicationPath & "\img\Hourglass.ani")
        Me.Cursor = New Cursor(Me.GetType, sApplicationPath & "\img\Hourglass.ani") 'Cursors.WaitCursor 'New Cursor(ms) 'cur 

        Dim _DLWriter As DLWriter
        Try
            _DLWriter = New DLWriter("")
            _DLWriter.WriteXLS(sFileName, dtRecordDetails, iEntertainmentType)
        Finally
            _DLWriter = Nothing
        End Try

        Me.Cursor = Cursors.Default
        My.Computer.Clipboard.SetText(sFileName)
        MessageBox.Show("Data has been exported to excel at: " & vbCrLf & sFileName & vbCrLf & vbCrLf & "File path has been copied to clipboard!", "Export successful")
    End Sub
End Class